<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:grupo5="http://grupo5" xmlns:xpdl="http://www.wfmc.org/2008/XPDL2.1">
	<xsl:output method="xml" indent="yes"  version="1.0" encoding="UTF-8" />
	
	<xsl:template match="workflow[position()=1]">
	
	  <xpdl:Package 
                xmlns:xpdl="http://www.wfmc.org/2008/XPDL2.1"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:grupo5="http://grupo5" 
                xsi:schemaLocation="http://www.wfmc.org/2008/XPDL2.1 bpmnxpdl_31.xsd"
                Id="a7065934-b35b-4bbe-9957-2cd5c9faa805" 
                Name="My Diagram">

	  <xpdl:PackageHeader>
	    <xpdl:XPDLVersion>2.1</xpdl:XPDLVersion>
	    <xpdl:Vendor></xpdl:Vendor>
	    <xpdl:Created></xpdl:Created>
	    <xpdl:Description />
	  </xpdl:PackageHeader>
	  <xpdl:RedefinableHeader>
	    <xpdl:Author>Grupo 5 -XML</xpdl:Author>
	    <xpdl:Version>1.0</xpdl:Version>
	  </xpdl:RedefinableHeader>
	  <xpdl:Participants />
	  <xpdl:Pools>
	    <xpdl:Pool Id="02b541b1-22a9-44f0-9004-c9c9e9a2116e" Name="Pattern1"  BoundaryVisible="false">
	      <xpdl:Lanes />
	      <xpdl:Object Id="02b541b1-22a9-44f0-9004-c9c9e9a2116e" Name="Pattern1" />
	      <xpdl:NodeGraphicsInfos />
	    </xpdl:Pool>
	  </xpdl:Pools> 
	  <xpdl:WorkflowProcesses>
    	<xpdl:WorkflowProcess ProcessType="None" Status="None"  >
    		
    		<xsl:attribute name="Id"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
    		<xsl:attribute name="Name"> <xsl:value-of select="@name"></xsl:value-of> </xsl:attribute>
    		<xsl:attribute name="grupo5:version"><xsl:value-of select="@version"></xsl:value-of> </xsl:attribute>
    		<xsl:attribute name="grupo5:vistrail_id"><xsl:value-of select="@vistrail_id"></xsl:value-of> </xsl:attribute>
    		<xsl:attribute name="grupo5:tipo">nada</xsl:attribute>
    		<xpdl:ProcessHeader>
                <xpdl:Created>2009</xpdl:Created>
            </xpdl:ProcessHeader>
    		<xpdl:Activities>
		 	 <xsl:apply-templates select="module" />
		 	 <xsl:apply-templates select="group" />
			 <xsl:apply-templates select="abstraction" />
		  	</xpdl:Activities>
		  	 <xpdl:Transitions>
		  	  <xsl:apply-templates select="connection" />
		  	 </xpdl:Transitions>
		  	 <xpdl:ExtendedAttributes>
		  	 	<xsl:apply-templates select="plugin_data" />
		  	 </xpdl:ExtendedAttributes>
		  	 
		 </xpdl:WorkflowProcess>
		 <xsl:for-each select="//group/workflow">
		 	<xpdl:WorkflowProcess ProcessType="None" Status="None"  >
    		
    		<xsl:attribute name="Id"><xsl:number></xsl:number> </xsl:attribute>
    		<xsl:attribute name="Name"> <xsl:value-of select="@name"></xsl:value-of> </xsl:attribute>
    		<xsl:attribute name="grupo5:version"><xsl:value-of select="@version"></xsl:value-of> </xsl:attribute>
    		<xsl:attribute name="grupo5:vistrail_id"><xsl:value-of select="@vistrail_id"></xsl:value-of> </xsl:attribute> 
    		<xsl:attribute name="grupo5:identificador"><xsl:value-of select="../annotation[@key='__desc__']/@value"></xsl:value-of> </xsl:attribute>
    		<xsl:attribute name="grupo5:tipo">group</xsl:attribute>
    		<xpdl:ProcessHeader>
                <xpdl:Created>2009</xpdl:Created>
            </xpdl:ProcessHeader>
    		<xpdl:Activities>
		 	 <xsl:apply-templates select="module" />
		 	 <xsl:apply-templates select="group" />
			 <xsl:apply-templates select="abstraction" />
		  	</xpdl:Activities>
		  	 <xpdl:Transitions>
		  	  <xsl:apply-templates select="connection" />
		  	 </xpdl:Transitions>
		  	 <xpdl:ExtendedAttributes>
		  	 	<xsl:apply-templates select="plugin_data" />
		  	 </xpdl:ExtendedAttributes>
		 </xpdl:WorkflowProcess>
		 </xsl:for-each>
		 
	   </xpdl:WorkflowProcesses>
	</xpdl:Package>
	</xsl:template>
	
	<xsl:template match="module">
		<xpdl:Activity >
			 <xsl:attribute name="Id"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
			 <xsl:attribute name="Name"><xsl:value-of select="@name"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:cache"><xsl:value-of select="@cache"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:namespace"><xsl:value-of select="@namespace"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:package"><xsl:value-of select="@package"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:version"><xsl:value-of select="@version"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:tag"><xsl:value-of select="@tag"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:tipo">module</xsl:attribute>
			 <xsl:apply-templates select="annotation[@key='__desc__']"></xsl:apply-templates>
			 <xpdl:InputSets>
			 		<xpdl:InputSet>
			 			<xsl:apply-templates select="portSpec[@type='input']"></xsl:apply-templates>
			 		    <xpdl:Input ArtifactId="999999999" />
			 		</xpdl:InputSet>
			 </xpdl:InputSets>
			 <xpdl:OutputSets>
			 	<xpdl:OutputSet>
			 			<xsl:apply-templates select="portSpec[@type='output']"></xsl:apply-templates>
			 			<xpdl:Output ArtifactId="999999999" />
			 	</xpdl:OutputSet>
			 </xpdl:OutputSets>
			 <xpdl:Assignments>
			 	<xsl:apply-templates select="function"></xsl:apply-templates>
			 	<xpdl:Assignment >
			 		<xpdl:Target></xpdl:Target>
			 		<xpdl:Expression></xpdl:Expression>
			 	</xpdl:Assignment>
			 </xpdl:Assignments>
			 	
			 <xsl:apply-templates select="location"></xsl:apply-templates>
		</xpdl:Activity>
	</xsl:template>
	<xsl:template match="group">	
		<xpdl:Activity >
			 <xsl:attribute name="Id"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
			 <xsl:attribute name="Name"><xsl:value-of select="@name"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:cache"><xsl:value-of select="@cache"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:namespace"><xsl:value-of select="@namespace"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:package"><xsl:value-of select="@package"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:version"><xsl:value-of select="@version"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:tag"><xsl:value-of select="@tag"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:tipo">group</xsl:attribute>
			 <xsl:apply-templates select="annotation[@key='__desc__']"></xsl:apply-templates>
			 <xpdl:Assignments>
			 	<xsl:apply-templates select="function"></xsl:apply-templates>
			 	<xpdl:Assignment >
			 		<xpdl:Target></xpdl:Target>
			 		<xpdl:Expression></xpdl:Expression>
			 	</xpdl:Assignment>
			 </xpdl:Assignments>
			 	
			 <xsl:apply-templates select="location"></xsl:apply-templates>
		</xpdl:Activity>
	</xsl:template>
	
	<xsl:template match="abstraction">	
		<xpdl:Activity >
			 <xsl:attribute name="Id"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
			 <xsl:attribute name="Name"><xsl:value-of select="@name"></xsl:value-of></xsl:attribute>
			  <xsl:attribute name="grupo5:cache"><xsl:value-of select="@cache"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:namespace"><xsl:value-of select="@namespace"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:package"><xsl:value-of select="@package"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:version"><xsl:value-of select="@version"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:tag"><xsl:value-of select="@tag"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:internalVersion"><xsl:value-of select="@internalVersion"></xsl:value-of></xsl:attribute>
			 <xsl:attribute name="grupo5:tipo">abstraction</xsl:attribute>
			 
			 <xsl:apply-templates select="annotation[@key='__desc__']"></xsl:apply-templates>
			 <xpdl:Assignments>
			 	<xsl:apply-templates select="function"></xsl:apply-templates>
			 	<xpdl:Assignment >
			 		<xpdl:Target></xpdl:Target>
			 		<xpdl:Expression></xpdl:Expression>
			 	</xpdl:Assignment>
			 </xpdl:Assignments>
			 	
			 <xsl:apply-templates select="location"></xsl:apply-templates>
		</xpdl:Activity>
	</xsl:template>
	
	<xsl:template match="connection">
		<xpdl:Transition>
			<xsl:attribute name="Id"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="From"><xsl:value-of select="port[@type='source']/@moduleId"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="To"><xsl:value-of select="port[@type='destination']/@moduleId"></xsl:value-of> </xsl:attribute>
			 <xpdl:ExtendedAttributes>
			 	<xpdl:ExtendedAttribute>
			 		<xsl:attribute name="Name">SourceId</xsl:attribute>
			 		<xsl:attribute name="Value"><xsl:value-of select="port[@type='source']/@id"></xsl:value-of> </xsl:attribute>
			 	</xpdl:ExtendedAttribute>
			 	<xpdl:ExtendedAttribute>
			 		<xsl:attribute name="Name">SourceModuleName</xsl:attribute>
			 		<xsl:attribute name="Value"><xsl:value-of select="port[@type='source']/@moduleName"></xsl:value-of> </xsl:attribute>
			 	</xpdl:ExtendedAttribute>
			 	<xpdl:ExtendedAttribute>
			 		<xsl:attribute name="Name">SourceName</xsl:attribute>
			 		<xsl:attribute name="Value"><xsl:value-of select="port[@type='source']/@name"></xsl:value-of> </xsl:attribute>
			 	</xpdl:ExtendedAttribute>
			 	<xpdl:ExtendedAttribute>
			 		<xsl:attribute name="Name">SourceSignature</xsl:attribute>
			 		<xsl:attribute name="Value"><xsl:value-of select="port[@type='source']/@signature"></xsl:value-of> </xsl:attribute>
			 	</xpdl:ExtendedAttribute>
			 	<xpdl:ExtendedAttribute>
			 		<xsl:attribute name="Name">DestinationId</xsl:attribute>
			 		<xsl:attribute name="Value"><xsl:value-of select="port[@type='destination']/@id"></xsl:value-of> </xsl:attribute>
			 	</xpdl:ExtendedAttribute>
			 	<xpdl:ExtendedAttribute>
			 		<xsl:attribute name="Name">DestinationModuleName</xsl:attribute>
			 		<xsl:attribute name="Value"><xsl:value-of select="port[@type='destination']/@moduleName"></xsl:value-of> </xsl:attribute>
			 	</xpdl:ExtendedAttribute>
			 		<xpdl:ExtendedAttribute>
			 		<xsl:attribute name="Name">DestinationName</xsl:attribute>
			 		<xsl:attribute name="Value"><xsl:value-of select="port[@type='destination']/@name"></xsl:value-of> </xsl:attribute>
			 	</xpdl:ExtendedAttribute>
			 	<xpdl:ExtendedAttribute>
			 		<xsl:attribute name="Name">DestinationSignature</xsl:attribute>
			 		<xsl:attribute name="Value"><xsl:value-of select="port[@type='destination']/@signature"></xsl:value-of> </xsl:attribute>
			 	</xpdl:ExtendedAttribute>
            </xpdl:ExtendedAttributes>
		</xpdl:Transition>
	</xsl:template>
	
	<xsl:template match="annotation">
		<xpdl:Description>
			<xsl:value-of select="@value"></xsl:value-of>
		</xpdl:Description>
	</xsl:template>
	
	<xsl:template match="location">
		<xpdl:NodeGraphicsInfos>
			<xpdl:NodeGraphicsInfo>
				<xpdl:Coordinates>
					<xsl:attribute name="grupo5:id"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
					<xsl:attribute name="XCoordinate"><xsl:value-of select="@x"></xsl:value-of> </xsl:attribute>
					<xsl:attribute name="YCoordinate"><xsl:value-of select="@y"></xsl:value-of> </xsl:attribute>
				</xpdl:Coordinates>
			</xpdl:NodeGraphicsInfo>
		</xpdl:NodeGraphicsInfos>
	</xsl:template>
	
	<xsl:template match="function">	
			<xpdl:Assignment>
				<xsl:attribute name="grupo5:id"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>			
				<xsl:attribute name="grupo5:pos"><xsl:value-of select="@pos"></xsl:value-of> </xsl:attribute>			
				<xsl:attribute name="grupo5:name"><xsl:value-of select="@name"></xsl:value-of> </xsl:attribute>
				<xpdl:Target></xpdl:Target>	
				<xpdl:Expression></xpdl:Expression>	
				<grupo5:Parametros>
						<xsl:apply-templates></xsl:apply-templates>
				</grupo5:Parametros>	
			</xpdl:Assignment>
	</xsl:template>
	
	<xsl:template match="parameter">
		<grupo5:Parametro >
			<xsl:attribute name="id"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="pos"><xsl:value-of select="@pos"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="name"><xsl:value-of select="@name"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="type"><xsl:value-of select="@type"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="val"><xsl:value-of select="@val"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="alias"><xsl:value-of select="@alias"></xsl:value-of> </xsl:attribute>
		</grupo5:Parametro>
	</xsl:template>
	
	<xsl:template match="portSpec[@type='input']">
		<xpdl:Input>
			<xsl:attribute name="ArtifactId"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:name"><xsl:value-of select="@name"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:type"><xsl:value-of select="@type"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:optional"><xsl:value-of select="@optional"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:sortKey"><xsl:value-of select="@sortKey"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:sigstring"><xsl:value-of select="@sigstring"></xsl:value-of> </xsl:attribute>
		</xpdl:Input>
	</xsl:template>
	
	<xsl:template match="portSpec[@type='output']">
		<xpdl:Output>
			<xsl:attribute name="ArtifactId"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:name"><xsl:value-of select="@name"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:type"><xsl:value-of select="@type"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:optional"><xsl:value-of select="@optional"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:sortKey"><xsl:value-of select="@sortKey"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="grupo5:sigstring"><xsl:value-of select="@sigstring"></xsl:value-of> </xsl:attribute>
		</xpdl:Output>
	</xsl:template>
	
	<xsl:template match="plugin_data">
		<xpdl:ExtendedAttribute>
			<xsl:attribute name="Name"><xsl:value-of select="@id"></xsl:value-of> </xsl:attribute>
			<xsl:attribute name="Value"><xsl:value-of select="@data"></xsl:value-of> </xsl:attribute>
		</xpdl:ExtendedAttribute>
	</xsl:template>
	
	
	
	
</xsl:stylesheet>